package com.gexin.model.user;

import com.gexin.common.utils.SQLUtils;
import com.gexin.common.utils.StringUtil;
import com.gexin.model.user.base.BaseFeedback;
import com.gexin.model.weixin.WeixinUser;
import com.jfinal.plugin.activerecord.Page;

/**
 * 业务名称:  t_feedback() 
 */
@SuppressWarnings("serial")
public class Feedback extends BaseFeedback<Feedback> {
	public static final Feedback dao = new Feedback();

	public Page<Feedback> feedbackList(int page , int pageSize , WeixinUser authUser) {
		SQLUtils sql = new SQLUtils(" from t_feedback fb left join t_weixin_user user on user.openid=fb.user_id where fb.user_id=? ");
		return paginate(page,pageSize,"select fb.*,user.username,user.nickname,user.headimgurl ",sql.toString(),authUser.getOpenid());
	}


	public Page<Feedback> findFeedbackList(int page , int pageSize , String content) {
		SQLUtils sql = new SQLUtils(" from t_feedback fb left join t_weixin_user user on user.id=fb.user_id where 1=1 ");
		if(!StringUtil.isBlank(content)){
			sql.whereLike("fb.content",content);
		}
		sql.append(" order by fb.create_time desc");
		return paginate(page,pageSize,"select fb.*,user.username,user.nickname,user.headimgurl ",sql.toString());
	}
}
